package com.example.gallery;

import android.app.Activity;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.ImageView;

import com.example.board.R;


public class FullImageActivity extends Activity implements OnClickListener{
	String IMAGE_PATH;
	int IMAGE_NO;
	int succ = 0;
	int BOARD_NO;
	String TAG = "FullImageActivity";
	
	
	ImageHandler imageDB;
	ImageView iv_fullimage;
	Button btn_delete;
	Button btn_back;
	
	
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		// TODO Auto-generated method stub
		super.onCreate(savedInstanceState);
		setContentView(R.layout.fullimage);
		btn_delete = (Button) findViewById(R.id.btn_delete);
		btn_back = (Button) findViewById(R.id.btn_back);
		
		iv_fullimage = (ImageView) findViewById(R.id.iv_fullimage);
		
		btn_delete.setOnClickListener(this);
		btn_back.setOnClickListener(this);
		
	}

	
	@Override
	protected void onResume() {
		// TODO Auto-generated method stub
		super.onResume();
		Intent intent = getIntent();
		IMAGE_PATH = intent.getExtras().getString("IMAGE_PATH");
		IMAGE_NO = intent.getExtras().getInt("IMAGE_NO");
		BOARD_NO = intent.getExtras().getInt("BOARD_NO");
		Log.i(TAG, "BOARD_NO : " +BOARD_NO +  "\nFULL_IMAGE_PATH : "+IMAGE_PATH+"\nIMAGE_NO : "+IMAGE_NO);
//		ImageListAdapter adapter = new ImageListAdapter(this);
//		Log.i(TAG, adapter.getItem(position)+"");
		
		iv_fullimage.setImageURI(Uri.parse(IMAGE_PATH));
		
	}
	
	@Override
	public void onClick(View v) {
		// TODO Auto-generated method stub
		switch (v.getId()) {
			case R.id.btn_delete:
				imageDB = ImageHandler.open(this);
				succ = imageDB.delete(IMAGE_NO);
				Log.i(TAG, "삭제 성공?? ......."+succ);
				if(succ > 0 ){
					finish();
				}
				
				break;

			case R.id.btn_back : 
			/*	Intent intent = new Intent(this, DetailActivity.class);
				intent.putExtra("no", String.valueOf(BOARD_NO));	//�Խñ� ��ȣ 
				startActivity(intent);*/
				finish();
				
			default:
				break;
		}
		
	}


	@Override
	protected void onPause() {
		// TODO Auto-generated method stub
		super.onPause();
	}

	@Override
	protected void onRestart() {
		// TODO Auto-generated method stub
		super.onRestart();
	}

	

	@Override
	protected void onStart() {
		// TODO Auto-generated method stub
		super.onStart();
	}

	@Override
	protected void onStop() {
		// TODO Auto-generated method stub
		super.onStop();
	}
	
}
